﻿using System.ComponentModel;
using System.ComponentModel.Composition;
using NthDownload.Common.Mapping;

namespace NthDownload.DownloadPlugins.Http
{
    [PartCreationPolicy(CreationPolicy.Shared)]
    [Export(typeof(HttpSettings))]
    [MappableObject]
    public class HttpSettings : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion INotifyPropertyChanged

        #region Class Members

        private string _defaultDestinationPath;
        private HttpCredentialsCollection _credentials;

        #endregion Class Members

        #region Constructor

        public HttpSettings()
        {
            DefaultDestinationPath = "";
            Credentials = new HttpCredentialsCollection();
        }

        #endregion Constructor

        #region Properties

        [MappableProperty]
        public string DefaultDestinationPath
        {
            get
            {
                return _defaultDestinationPath;
            }
            set
            {
                _defaultDestinationPath = value;
                OnPropertyChanged("DefaultDestinationPath");
            }
        }

        [MappableProperty]
        public HttpCredentialsCollection Credentials
        {
            get
            {
                return _credentials;
            }
            set
            {
                _credentials = value;
                OnPropertyChanged("Credentials");
            }
        }

        #endregion Properties
    }
}
